package com.hctforgreen.greenservice.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * download book 是否完成初始化Util
 * 
 * @author Tallen Zhai
 * 
 */
public class DownloadBookLstInitFinishUtil {

	
	public static void saveInitFinished(Context activity,
										 boolean bInitFinished) {
		SharedPreferences sharedPreferences = activity.getSharedPreferences(
				HctConstants.DOWNLOAD_BOOK_LST_INIT_FINISH_FILE_NAME,
				Context.MODE_WORLD_WRITEABLE);
		Editor editor = sharedPreferences.edit();

		editor.putBoolean(HctConstants.DOWNLOAD_BOOK_LST_INIT_FINISH_KEY_VALUE, bInitFinished);
		editor.commit();
	}


	public static boolean getInitFinished(Context activity) {
		SharedPreferences sharedPreferences = activity.getSharedPreferences(
				HctConstants.DOWNLOAD_BOOK_LST_INIT_FINISH_FILE_NAME,
				Context.MODE_WORLD_WRITEABLE);
		boolean bInitFinish = sharedPreferences.getBoolean(
				HctConstants.DOWNLOAD_BOOK_LST_INIT_FINISH_KEY_VALUE, false);

		return bInitFinish;
	}

	public static void saveDownloadBookFinished(Context activity,
										boolean bInitFinished) {
		SharedPreferences sharedPreferences = activity.getSharedPreferences(
				HctConstants.DOWNLOAD_BOOK_FINISH_FILE_NAME,
				Context.MODE_WORLD_WRITEABLE);
		Editor editor = sharedPreferences.edit();

		editor.putBoolean(HctConstants.DOWNLOAD_BOOK_FINISH_KEY_VALUE, bInitFinished);
		editor.commit();
	}


	public static boolean getDownloadBookFinished(Context activity) {
		SharedPreferences sharedPreferences = activity.getSharedPreferences(
				HctConstants.DOWNLOAD_BOOK_FINISH_FILE_NAME,
				Context.MODE_WORLD_WRITEABLE);
		boolean bInitFinish = sharedPreferences.getBoolean(
				HctConstants.DOWNLOAD_BOOK_FINISH_KEY_VALUE, false);

		return bInitFinish;
	}

	public static void saveUpdateBookServiceFinished(Context activity,
												boolean bInitFinished) {
		SharedPreferences sharedPreferences = activity.getSharedPreferences(
				HctConstants.UPDATE_BOOK_OPEN_FILE_NAME,
				Context.MODE_WORLD_WRITEABLE);
		Editor editor = sharedPreferences.edit();

		editor.putBoolean(HctConstants.UPDATE_BOOK_OPEN_KEY_VALUE, bInitFinished);
		editor.commit();
	}


	public static boolean getUpdateBookServiceFinished(Context activity) {
		SharedPreferences sharedPreferences = activity.getSharedPreferences(
				HctConstants.UPDATE_BOOK_OPEN_FILE_NAME,
				Context.MODE_WORLD_WRITEABLE);
		boolean bInitFinish = sharedPreferences.getBoolean(
				HctConstants.UPDATE_BOOK_OPEN_KEY_VALUE, false);

		return bInitFinish;
	}
}
